package name.fowler.refactoring.simplestore;

import java.util.ArrayList;
import java.util.List;

public class Customer {
	private String m_Name;
	private List<Rental> m_Rentals = new ArrayList<Rental>();
	
	public Customer(String name) {
		m_Name = name;
	}

	public String getName() {
		return m_Name;
	}


	public void addRental(Rental arg){
		m_Rentals.add(arg);
	}

	public StatementResult Statement()
	{
		int frequentRenterPoints = 0;
		StatementResult result = new StatementResult(m_Name);
		
		for(Rental each: m_Rentals) {
			double thisAmount = each.getAmount();

			// Add frequent renter points
			frequentRenterPoints += each.getFrequentPoints();

			// Show figures for this rental
			result.addMovie(each.getMovie().getTitle(), thisAmount);
		}

		// Add footer lines
		result.setFrequentRenterPoints(frequentRenterPoints);
		return result;
	}
}

